<!DOCTYPE html>
<html>
<head>
	{include file="common_header" /}
	{include file="common_top" /}
</head>
<body>

  <div class="layui-fluid">
    <div class="layui-card">
      <div class="layui-card-header">修改管理员</div>
      <div class="layui-card-body" style="padding: 15px;">
        <form class="layui-form" action="" lay-filter="component-form-group">

          
          <div class="layui-form-item">
            <label class="layui-form-label">用户名称</label>
            <div class="layui-input-block">
              <input name="username" type="text" disabled class="layui-input" id="username" value="{$info['m_username']}" readonly="readonly"   placeholder="用户名称">
            </div>
          </div>
		  
		  <div class="layui-form-item">
            <label class="layui-form-label">用户密码</label>
            <div class="layui-input-block">
              <input type="password" name="password" id="password"   placeholder="用户密码" class="layui-input">
            </div>
          </div>
		  
		  
		  <div class="layui-form-item">
            <label class="layui-form-label">确认密码</label>
            <div class="layui-input-block">
              <input type="password" name="endpassword" id="endpassword"   placeholder="确认密码" class="layui-input">
            </div>
          </div>
		  
		 

          <div class="layui-form-item">
            <label class="layui-form-label">用户状态</label>
            <div class="layui-input-block">
              <input type="radio" name="status" value="1" title="启用" {if $info['m_status']==1}checked{/if}>
              <input type="radio" name="status" value="2" title="禁用" {if $info['m_status']==2}checked{/if}>
            </div>
          </div>
		  
		  
		  <div class="layui-form-item">
            <label class="layui-form-label">所属群组</label>
            <div class="layui-input-block">
				{volist name="list" id="vo"}
              <input type="radio" name="group" value="{$vo.g_id}" title="{$vo.g_title}" {if $info['g_id']==$vo.g_id}checked{/if}>
             {/volist}
            </div>
          </div> 

		  
          <div class="layui-form-item layui-layout-admin">
            <div class="layui-input-block">
              <div class="layui-footer" style="left: 0;">
                <div class="layui-btn sub">立即提交</div>
                <button type="reset" class="layui-btn layui-btn-primary ">重置</button>
              </div>
            </div>
          </div>
        </form>
      </div>
    </div>
  </div>
{include file="common_footer" /} 
<script>
$(".sub").click(function(){
	//if(!$(".btn").hasClass("sub")){return false;}
	var password    = $("#password").val();
	var endpassword = $("#endpassword").val();
	var status      = $("input[name='status']:checked").val();
	var group       = $("input[name='group']:checked").val();
	
	if(password != "" || endpassword != ""){
		
		if(password == ""){
			show_toast("{$language['manage_user_empty_password']}");
			return false
		}
		
		if(endpassword == ""){
			show_toast("{$language['manage_user_empty_endpassword']}");
			return false
		}
		
		if(password != endpassword){
			show_toast("{$language['manage_user_error_password_and_endpassword']}");
			return false
		}
	}
	
	if(typeof(group) == "undefined"){
		show_toast("{$language['manage_user_empty_group']}");
		return false
	}

	
	
	$.ajax({
		type:"POST",
		url:"{:url('manage/manageedit')}",
		dataType:"json",
		data:{
			id:{$info['m_id']},
			password:password,
			status:status,
			group:group,
		},

		success:function(res){
			
			if(res.status == "success"){
				show_toast_callurl(res.data,"{:url('manage/index')}","success");
			}else{
				show_error(res.data);
			}
		},
		error:function(jqXHR){
			console.log("Error: "+jqXHR.status);
		},
	});
	
});
</script>
</body>
</html>
